home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{02B5E320-7292-11CF-93D5-0020AF99504A}#1.0#0"; "MSCHART.OCX"
- Begin VB.Form Form1
- Caption = "Form1"
- ClientHeight = 5040
- ClientLeft = 1095
- ClientTop = 825
- ClientWidth = 7200
- LinkTopic = "Form1"
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 5040
- ScaleWidth = 7200
- Begin MSChartLib.MSChart Chart1
- Height = 4815
- Left = 120
- OleObjectBlob = "Form1.frx":0000
- TabIndex = 0
- Top = 120
- Width = 6975
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Private Values() As Single
- Private NumPoints As Integer
- Private Sub LoadData()
- Dim db As Database
- Dim qdef As QueryDef
- Dim rs As Recordset
- Dim dbname As String
- Dim i As Integer
- ' Open the database.
- dbname = App.Path
- If Right$(dbname, 1) <> "\" Then dbname = dbname & "\"
- dbname = dbname & "data.mdb"
- Set db = OpenDatabase(dbname)
- ' Get the records.
- Set qdef = db.CreateQueryDef("", _
- "SELECT Year, Value FROM YearlyValues")
- Set rs = qdef.OpenRecordset(dbOpenSnapshot)
- ' See how many records there are.
- rs.MoveLast
- NumPoints = rs.RecordCount
- ReDim Values(1 To NumPoints, 1 To 2)
- ' Load the data.
- rs.MoveFirst
- For i = 1 To NumPoints
- Values(i, 1) = Format$(rs!Year, "yyyy")
- Values(i, 2) = rs!Value
- rs.MoveNext
- Next i
- rs.Close
- db.Close
- End Sub
- Private Sub MakeData()
- Const NUM_POINTS = 40
- Dim db As Database
- Dim dbname As String
- Dim i As Integer
- Dim the_year As Date
- Dim the_value As Single
- Dim sql As String
- ' Open the database.
- dbname = App.Path
- If Right$(dbname, 1) <> "\" Then dbname = dbname & "\"
- dbname = dbname & "data.mdb"
- Set db = OpenDatabase(dbname)
- ' Delete any old data.
- sql = "DELETE FROM YearlyValues"
- db.Execute sql
- ' Create a bunch of data.
- the_year = #1/1/60#
- the_value = 1000
- For i = 1 To 38
- sql = "INSERT INTO YearlyValues VALUES (#" & _
- Format$(the_year) & "#, " & _
- Format$(the_value) & ")"
- db.Execute sql
-
- the_year = DateAdd("yyyy", 1, the_year)
- the_value = the_value + Rnd * 2
- Next i
- db.Close
- End Sub
- Private Sub Form_Load()
- Const MAKING_DATA = False
- If MAKING_DATA Then
- MakeData
- Unload Me
- Else
- LoadData
- ' Send the data to the chart.
- Chart1.chartType = VtChChartType2dXY
- Chart1.RowCount = NumPoints
- Chart1.ColumnCount = 2
- Chart1.ChartData = Values
- End If
- End Sub
-